<template>
    <div>
        <div><Table border :columns="columns" :data="data"></Table></div>
      <transition name="bidding-detail">
              <div class="bidding-block" v-if="authorizeDtail">
                 <div class="bidding-block-top">
                            <div class="bidding-block-close" @click="closeauthorizedtail"><!--左上角关闭动作-->
                                <Icon type="md-close"/>
                            </div>
                            <span>项目详情</span>
                      </div>
                  <div class="undertake-title">
                    <button class="undertake-title" @click.prevent="which='easynews'">项目基本信息</button>
                    <button class="undertake-title" @click.prevent="which='authorizenews'">编制信息</button>
                    <button class="undertake-title" @click.prevent="which='finacenews'">财务信息</button>
                    <button class="undertake-title" @click.prevent="which='projectprogress'">项目进展</button>
                  </div>
                  <keep-alive>
                      <component v-bind:is="which" :callbackdata="callbackdata"></component> 
                  </keep-alive>
                  <div>
                    <Button type="primary" @click="closeauthorizedtail">确定</Button>
                  </div>                                    

              </div>              
             </transition>
    </div>
    
</template>
<script>
import axios from 'axios';
export default {
    name:'authorizetable',
    data(){
        return{
            row:{},
            pageNum: 1,
            pageSize: 10,
            modelId:3,
            callbackdata:{},//返回数据
            which:'easynews',

            authorizeDtail:false,
            columns:[
        {
          type: "selection",
          width: 60,
          align: "center",
          fixed: "left"
        },
        {
          title: "序号",
          key: "id"
        },
        {
          title: "操作",
          fixed: "right",
          key:"number",
          width: 120,
          render:(h,params) => {
            return h(
              "Dropdown",
              {
                on:{
                  "on-click": name =>{
                    let rowData = params.row;
                    let id = rowData.id;
                    if(name=='read'){
                        this.row=id;
                        this.setBackdata();
                        this.authorizeDtail=true;

                    }else if(name=='edit'){
                      this.orgDtailedit=true;
                    }else if(name=='export'){
                      
                    }
                  }
                },
                props: {
                  transfer: true
                }
              },
              [
                h(
                  "Button",
                  {
                    props: {
                      type: "primary"
                    }
                  },
                  "操作>>"
                ),
                h(
                  "DropdownMenu",
                  {
                    slot: "list"
                  },
                  [
                    h(
                      "DropdownItem",
                      {
                        props: {
                          name: "read"
                        }
                      },
                      "查看详情"
                    ),
                    h(
                      "DropdownItem",
                      {
                        props: {
                          name: "edit"
                        }
                      },
                      "编制项目"
                    ),
                    h(
                      "DropdownItem",
                      {
                        props: {
                          name: "export"
                        }
                      },
                      "导出任务单"
                    ),
                  ]
                )
              ]
            )
          },
        }
      ],
      data:[
        
      ],
      select1:null,
      select2:null,
      select3:null

        };
    },
    beforeMount(){
        this.getTable();//产生表信息
        this.getcolumns(); //产生表头

    },
    // created:function(){
    //   this.select1=this.callbackdata1.select1;
    //   this.select2=this.callbackdata1.select2;
    //   this.select3=this.callbackdata1.select3;
    //     console.info("123");      
    //     console.log(this.callbackdata1);
    // },
    props:['callbackdata1'],
    watch:{
      callbackdata1:{
        handler:function(val,oldval){
          // console.info("111");
          // console.log(this.callbackdata1);
        }
      }

    },
    // computed:{
    //   changeSelect:(newVal,oldVal)=>{
    //     console.log(newVal);
        
    //   }

    // },
    methods:{
      getNewData() {
      this.data = [];
      // console.info("select123");
      // console.log(this.select1);
      // console.log(this.select2);
      // console.log(this.select3);
      this.$ajax({
        method: "post",
        url: "http://47.101.180.43:8080/table/show",
        params: {
          pageNum: 1,
          pageSize: 10,
          modelId: 3
        },
        data: {
          undertakePersonId: this.select2,
          undertakeDepartmentId: this.select1,
          registDate: this.select3
        }
      }).then(response => {
        this.data = response.data.data.data.list;
        //console.info('111');
        //console.log(fields);
       
      });
    },
        closeauthorizedtail(){
            let that = this;
        this.$Modal.confirm({
            title: "确定关闭吗？",
            onOk() {
            that.authorizeDtail = false;
            
            }
        });

        },
        getcolumns(){
      axios({
          method: 'post',
          url: 'http://47.101.180.43:8080/table/show?pageNum='+ this.pageNum+'&pageSize='+ this.pageSize + '&modelId='+this.modelId,

          }).then(result=>{
              let that = this;
              
              var fields=result.data.data.fields;
              var attribute=result.data.data.attribute;
              //var list=result.data.data.data.list;
              var i=0;
              // console.log(result);   
              for(i;i<fields.length;i++){
                this.columns.push({
                  title:fields[i],
                  key:attribute[i]
                })
              } 
              //this.data=list;      

            })

    },
    getTable(){
    
          axios({
          method: 'post',
          url: 'http://47.101.180.43:8080/table/show?pageNum='+ this.pageNum+'&pageSize='+ this.pageSize + '&modelId='+this.modelId,

          }).then(result=>{
              let that = this;
              
              var list=result.data.data.data.list;
              //var i=0;
              // console.log(result);   
              
              this.data=list;      

            })
    },
        setBackdata(){
            // console.log(this.row);
            this.callbackdata=this.row;

        }
    }
}
</script>

